<%- include('../views/layout/hearder.ejs') %>

  <h1>文章列表</h1>

  <div class="list-group" style="margin: 10px;">
    <% articles.forEach(item => { %>
      <a href="/article/info/<%= item.id %>" class="list-group-item">
        <%= item.title %>
        <span class="badge" style="background-color: #5bc0de;">发表时间：<%= item.ctime %></span>
        <span class="badge" style="background-color: #f0ad4e;">作者昵称：<%= item.nickname %></span>
      </a>
      <% }) %>
  </div>

  <!-- 分页区域 -->
  <nav aria-label="Page navigation">
      <ul class="pagination">
        <li class="<%= nowpage-1 === 0 ? 'disabled' : '' %>">
          <<%= nowpage-1 === 0 ? 'span' : 'a' %> href="?page=<%= nowpage-1 === 0 ? 1 : nowpage-1 %>" aria-label="Previous">
            <span aria-hidden="true">&laquo;</span>
          </<%= nowpage-1 === 0 ? 'span' : 'a' %>>
        </li>
        <% for(var i = 0; i < totalPage; i++){ %>
        <li class="<%= nowpage === (i+1) ? 'active' : '' %>"><a href="?page=<%= i+1 %>"><%= i+1 %></a></li>
        <% } %>
        <li class="<%= nowpage+1 > totalPage ? 'disabled' : ''  %>">
          <<%= nowpage+1 > totalPage ? 'span' : 'a'  %> href="?page=<%= nowpage+1 > totalPage ? totalPage : nowpage+1  %>" aria-label="Next">
            <span aria-hidden="true">&raquo;</span>
          </<%= nowpage+1 > totalPage ? 'span' : 'a'  %>>
        </li>
      </ul>
    </nav>

  <%- include('../views/layout/footer.ejs') %>